import time

# 装饰的入参fn是被修饰的函数
def getTime(fn):
    def wapper():
        startTime = time.time()
        fn()
        endTime = time.time()
        print("该函数的执行时间为{}".format(endTime - startTime))
    return wapper



# 定义一个装饰器可以求出任意一个函数的执行时间
@getTime
def runA():
    for i in range(100):
        print(i)

@getTime
def runB():
    for i in range(100):
        print(i)

runA()
runB()

